﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Models;
using ImpServices;
using IServices;
namespace MVCCompany.Controllers
{
    public class CategoryController : Controller
    {
        private readonly ICategoryServices _categoryServices;
        //实现CategoryController的构造函数 这样有利于实现IOC的依赖注入Autofac
        public CategoryController(ICategoryServices categoryServices)
        {
            this._categoryServices = categoryServices;
        }

        //
        // GET: /Category/
        public ICategoryServices CategoryServices
        {
            get
            {
                return _categoryServices;
            }
        }

        public ActionResult Index()
        {
            ICategoryServices cateServices = CategoryServices;
            List<CategoryInfo> cateList = cateServices.GetAll();
            ViewBag.Cate = cateList;
            return View(cateList);
        }




    }
}
